home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Hot Mix 17
/
Hot Mix 17.iso
/
HM17_SGI
/
research
/
lib
/
bisect_pdf.pro
< prev
next >
Wrap
Text File
|
1997-07-08
|
1KB
|
46 lines
;$Id: bisect_pdf.pro,v 1.4 1997/01/15 03:11:50 ali Exp $
;
; Copyright (c) 1994-1997, Research Systems, Inc. All rights reserved.
; Unauthorized reproduction prohibited.
;+
; NAME:
; BISECT_PDF
;
; PURPOSE:
; This function computes the cutoff value x such that the probabilty
; of an observation from the given distribution, less than x, is a(0).
; u and l are the upper and lower limits for x, respectively.
; a(1) and a(2) are degrees of freedom, if appropriate.
; funct is a string specifying the probability density function.
; BISECT_PDF is not intended to be a user-callable function.
;-
function bisect_pdf, a, funct, u, l, del
sa = size(a)
if (n_elements(del) eq 0) then del = 1.0e-6
p = a[0]
if (p lt 0 or p gt 1) then return, -1
up = u
low = l
mid = l + (u - l) * p
count = 1
while (abs(up - low) gt del*mid) and (count lt 100) do begin
if n_elements(z) ge 1 then begin
if z gt p then up = mid else low = mid
mid = (up + low)/2.
endif
case n_elements(a) of
1: z = call_function(funct, mid)
2: z = call_function(funct, mid, a[1])
3: z = call_function(funct, mid, a[1], a[2])
else: return, -1
endcase
count = count + 1
endwhile
return, mid
end